import { getList as getMesSalesOrderList, getOrderStatusList } from "@/api/order/mesProdOrder"

export const mesSalesOrderDialog = {
  data() {
    return {
      mesSalesOrderDialogVisible: false, //表格弹框隐藏显示
      getMesSalesOrderList, // 获取弹框数据接口
      hasMesSalesOrderFooter: true, // 是否需要底部按钮默认true
      mesSalesOrderSearchDialog: {
        inline: true,
        formDesc: {
          orderCode: {
            type: "input",
            layout: 8,
            label: $i18n.t("mesFqcTask.productWorkOrderCode")
          },
          orderStatus: {
            type: "select",
            label: $i18n.t("mesFqcTask.workOrderStatus"),
            layout: 8,
            prop: {
              value: "value",
              text: "description"
            },
            options: async (data) => {
              const list = await getOrderStatusList()
              return list.data.result
            }
          }
        }
      },
      mesSalesOrderDialogColumn: [
        {
          type: "selection"
        },
        {
          type: "index",
          label: $i18n.t("common.order"),
          width: 60,
          fixed: "left"
        },

        {
          prop: "planCode",
          label: $i18n.t("mesFqcTask.productionOrderCode"),
          width: 160
        },
        {
          prop: "orderCode",
          label: $i18n.t("mesFqcTask.productWorkOrderCode"),
          minWidth: 180
        },

        {
          prop: "prodCode",
          label: $i18n.t("mesFqcTask.productCode"),
          width: 150
        },
        {
          prop: "prodName",
          label: $i18n.t("mesFqcTask.productName"),
          width: 250,
          showOverflowTooltip: true
        },
        // {
        //   prop: "priority",
        //   label: "订单优先级",
        //   width: 120,
        // },
        {
          prop: "quantity",
          label: $i18n.t("mesFqcTask.planQuantity"),
          minWidth: 120
        },
        {
          prop: "actualQuantity",
          label: $i18n.t("mesFqcTask.actualQuantity"),
          minWidth: 120
        },
        {
          prop: "planBeginDate",
          label: $i18n.t("mesFqcTask.planBeginDate"),
          width: 130
        },

        {
          prop: "orderStatus",
          label: $i18n.t("mesFqcTask.workOrderStatus"),
          minWidth: 140,
          optionProp: {
            value: "value",
            label: "description"
          },
          option: async (data) => {
            const list = await getOrderStatusList()
            return list.data.result
          }
        },

        {
          prop: "lineName",
          label: $i18n.t("common.lineName"),
          minWidth: 200
        },
        {
          prop: "remark",
          label: $i18n.t("common.remark")
        },

        {
          prop: "createTime",
          label: $i18n.t("common.createTime"),
          width: 180
        },

        {
          prop: "updateTime",
          label: $i18n.t("common.updateTime"),
          width: 180
        }
      ]
    }
  },
  methods: {
    // 弹框表格，双击表格，或者点击确定 返回选中数据
    getSelectMesSalesOrder(data) {
      // 调试完成记得删除控制台打印
      // console.log("选中数据", data);
      // 这里可以自定义返回字段信息
      // 第一个入参为当前表单绑定的对象，第二个入参为要修改的字段名，第三个入参为选中数据中相应信息
      this.$set(this.formDataDialog, "planCode", data[0].planCode)
      this.$set(this.formDataDialog, "orderCode", data[0].orderCode)
      this.$set(this.formDataDialog, "prodCode", data[0].prodCode)
      this.$set(this.formDataDialog, "prodName", data[0].prodName)
    }
  }
}
